Developing in a Docker container
I develop inside Docker containers. Not because it’s trendy, but because it solves a real problem: my local machine stays clean, the project environment is reproducible, and I can hand the project to someone else (or a CI pipeline) and have it work the same way.
The part that makes it practical for active development — not just for running finished code — is combining Docker with bind mounts and VSCode’s remote development extension. Here’s how to set it up.
The basic idea: a Docker container runs your code in an isolated environment, but without bind mounts, editing the code means rebuilding the image every time. A bind mount connects a folder on your host machine directly to a folder inside the container, so changes you make in your editor are immediately visible to the running container. No rebuild required.
Step by step
1. Install Docker from the official Docker website for your operating system.
2. Create a Dockerfile in your project root. A minimal Python example:
# Use an official Python runtime as the base image
FROM python:3.10.6-buster
COPY requirements.txt /requirements.txt
RUN pip install --upgrade pip RUN pip install -r requirements.txt
# Set the working directory
WORKDIR /app
# Define the command to run when the container starts
CMD \["bash"\]3. Build the image:
docker build -t myapp .myapp is the image name; the . points to the current directory as the build context.
4. Run the container with a bind mount:
docker run -d -it --hostname yourname -v /path/to/folder/holding/the/source/code:/app myapp-d runs it detached, -it keeps stdin open, --hostname sets the container’s hostname, and -v is the bind mount — your local source folder gets mounted at /app inside the container. Any file you edit locally is immediately reflected inside the running container.
5. Connect VSCode to the container. Install the Docker extension:

Once installed, click the Docker icon in the left sidebar. You’ll see your running containers:

And the /app folder inside the container:

Right-click the container and select Attach Visual Studio Code. A new VSCode window opens, running inside the container. You’re now editing files directly in the container environment — but because of the bind mount, those edits also show up on your local filesystem. Any changes propagate in both directions.
The result: a consistent, reproducible development environment that’s isolated from your local machine, with a development experience that feels no different from editing files locally.